package com.fz.us.admin.base.bean.search.result;

import com.fz.us.admin.base.bean.search.Search;
import org.springframework.util.Assert;

/**
 * 查询 - 结果 - SearchResultUnique
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-07-13 。
 * ============================================================================
 */
public class SearchResultUnique extends SearchResult {

    private final Object object;

    public Object getObject() {
        return object;
    }

    private SearchResultUnique(Search search, Object object) {
        super(search);
        this.object = object;
    }

    public static SearchResultUnique uniqueResult(Search search, Object object) {
        return newBuilder().setSearch(search).setObjcet(object).build();
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public static class Builder extends SearchResult.Builder<SearchResult, Builder> {

        private Object object;

        @Override
        protected Builder getThis() {
            return this;
        }

        public Builder setObjcet(Object object) {
            this.object = object;
            return this;
        }

        @Override
        public SearchResultUnique build() {
            Assert.notNull(search, "search 不能为空");
            return new SearchResultUnique(search, object);
        }

    }

}
